import java.sql.*;

public class test {
    public static void main(String[] args) {
        import Connection;
        import DriverManager;
        import PreparedStatement;
        import ResultSet;
        import SQLException;

        public class DBUtil {

        	//数据库5大参数

        	private static final String IP = "127.0.0.1";
        	private static final String PORT = "3306";
        	private static final String DATABASE_NAME = "noticedb";
        	private static final String USER_NAME = "root";
        	private static final String PASSWORD = "123456";
        	private static final String DRIVER = "org.gjt.mm.mysql.Driver";

        	/*
        	//百度云
        	private static final String IP = "sqld.duapp.com";
        	private static final String PORT = "4050";
        	private static final String DATABASE_NAME = "PchRAwHEgyLYkrrqWqLW";
        	private static final String USER_NAME = "3201558798f34749ac4ee6d631eda289";
        	private static final String PASSWORD = "6b7c5e2c4ae54b4fa707876d047e0ce3";
        	private static final String DRIVER = "org.gjt.mm.mysql.Driver";
        	*/

        	public static Connection getConnection() throws Exception {
        		String url = "jdbc:mysql://"+IP+":"+PORT+"/"+DATABASE_NAME+"?user="+USER_NAME+"&password="+PASSWORD+"";
        		Class.forName(DRIVER);
        		Connection conn = DriverManager.getConnection(url);
        		//System.out.println("ConnManager已经创建了连接："+conn);
        		return conn;
        	}

        	public static void close(Connection conn){
        		try {
        			conn.close();
        		} catch (SQLException e) {
        			System.out.println("conn连接关闭错误"+e.getMessage());
        		}

        	}

        	public static void close (PreparedStatement pst){
        		try {
        			pst.close();
        		} catch (SQLException e) {
        			System.out.println("pst连接关闭错误"+e.getMessage());
        		}
        	}

        	public static void close(ResultSet rs){
        		try {
        			rs.close();
        		} catch (SQLException e) {
        			System.out.println("rs连接关闭错误"+e.getMessage());
        		}

        	}



        }

    }
}
